package com.example.demoapp.brvah.itemProvider;

import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.example.demoapp.R;
import com.example.demoapp.brvah.bean.MultipleItemBean;

import org.jetbrains.annotations.NotNull;


public class ArticleProvider extends BaseItemProvider<MultipleItemBean> {
    @Override
    public int getItemViewType() {
        return MultipleItemBean.TYPE_DOCUMENT;
    }

    @Override
    public int getLayoutId() {
        return R.layout.provider_article;
    }

    @NotNull
    @Override
    public BaseViewHolder onCreateViewHolder(@NotNull ViewGroup parent, int viewType) {
        return super.onCreateViewHolder(parent, viewType);
    }
    @Override
    public void convert(@NotNull BaseViewHolder baseViewHolder, MultipleItemBean multipleItemBean) {
        baseViewHolder.setText(R.id.title, multipleItemBean.getTitle());
        TextView descView = baseViewHolder.getView(R.id.desc);
        TextView authorView = baseViewHolder.getView(R.id.author);
        TextView likecount = baseViewHolder.getView(R.id.likecount);
        String desc = multipleItemBean.getSubtitle();
        if(desc==null||desc.equals("")){
            descView.setVisibility(View.GONE);
            authorView.setPadding(0,0,0,0);
        }else{
            descView.setVisibility(View.VISIBLE);
            authorView.setPadding(10,0,10,0);
            descView.setText(desc);
        }
//        authorView.setText(multipleItemBean.getAuthor());
        likecount.setText(String.valueOf(multipleItemBean.getAgree()));
        baseViewHolder.setText(R.id.date, multipleItemBean.getCreateTime().split(" ")[0]);
    }
}
